#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _

# Create your models here.
GENDER_CHOICES = (
    ('M', _('Male')),
    ('F', _('Female')),
)
class Profile(models.Model):
    """Employee

    """
    # User.attribute: username, first_name, last_name, email, password, 
    # is_staff, is_active, is_superuser, last_login, date_joined
    user = models.OneToOneField(User, primary_key=True)
    report_to = models.ForeignKey('self', null=True, blank=True)
    # profile
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, radio_admin=True)
    identification = models.CharField(max_length=18, unique=True)
    birthday = models.DateField()
    tel = models.CharField(max_length=50)
    portrait = models.ImageField(upload_to='photo', blank=True, null=True)

    class Meta:
        pass

    class Admin:
        list_display = ('user', 'gender', 'identification', 'birthday', 'tel', 'portrait')

    def __unicode__(self):
        return self.user.username

    def get_portrait(self):
        if self.portrait:
            return self.get_portrait_url()
        else:
            return 'images/default.png'
